﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JovensIPR.bean;

namespace JovensIPR.membro
{
    public partial class MembroCadastro : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                tbxDataCadastro.Text = DateTime.Today.ToString("dd/MM/yyyy");
            }
        }

        protected void btnCancelar_Click(object sender, EventArgs e)
        {
            ResetPage();
        }

        protected void btnConfirmar_Click(object sender, EventArgs e)
        {
            string message = String.Empty;

            Person person = UpdatePessoaOfDisplay();
        }

        private Person UpdatePessoaOfDisplay()
        {
            Person person = new Person();

            if (String.IsNullOrEmpty(Convert.ToString(Session["PERSON"])))
                person.Handle = Convert.ToInt64(Session["PERSON"]);

            person.Nome = tbxNome.Text.Trim();
            person.Email = tbxEmail.Text.Trim();
            person.Senha = tbxSenha.Text.Trim();
            person.DataCadastro = Convert.ToDateTime(tbxDataCadastro.Text.Trim());
            person.DadosAdicional = tbxDadosAdicional.Text.Trim();

            tbxEstado.Text = String.Empty;
            tbxCep.Text = String.Empty;
            tbxEndereco.Text = String.Empty;
            tbxNumero.Text = String.Empty;
            tbxBairro.Text = String.Empty;
            tbxComplemento.Text = String.Empty;
            return person;
        }

        private void ResetPage()
        {
            //Limpar campos do tipo TextBox
            tbxNome.Text = String.Empty;
            tbxEmail.Text = String.Empty;
            tbxSenha.Text = String.Empty;
            tbxConfirmaSenha.Text = String.Empty;
            tbxEstado.Text = String.Empty;
            tbxCep.Text = String.Empty;
            tbxEndereco.Text = String.Empty;
            tbxNumero.Text = String.Empty;
            tbxBairro.Text = String.Empty;
            tbxComplemento.Text = String.Empty;
            tbxDataCadastro.Text = DateTime.Today.ToString("dd/MM/yyyy");
            tbxDataNascimento.Value = String.Empty;
            
            tbxDadosAdicional.Text = String.Empty;

            //select
            slcCidade.SelectedIndex = -1;
            slcMembro.SelectedIndex = -1;
            slcParticipaGrupo.SelectedIndex = -1;
            slcGrupoParticipacao.SelectedIndex = -1;
        }
    }
}